define(function(require, exports){
	var $ = require('jquery');
	var pubjs = require('pubjs');
	var grid = require('@base/highGrid');
	var baseNoDate = require('@base/grid').baseNoDate;

	var Product = grid.base.extend({
		init: function(config){
			config = pubjs.conf(config, {
					url: 'product/list',
					cols: [
						{name:'_id',text:"ID", sort: true, width: 60, align: 'center'},
						'ProductNameWithThumb'
						//{name:'Name',text:"名称", type:'index', width: 200}
					],
					param: {
						order: 'impressions|-1'
					},
					default_metrics : pubjs.config('defaultMetrics'),
					subs: ['campaign', 'mediaAndAd', 'sweety', 'whisky', 'period', 'frequency', 'region', 'client'],
					reqType: 'websocket',
					gridName: 'product'
				}
			);
			this.Super('init', arguments);
		}
	});
	exports.base = Product;

	var SelectList = baseNoDate.extend({
		init: function(config){
			config = pubjs.conf(config, {
				'hasTab': false,
				'hasAmount': false,
				'hasExport': false,
				'sub_field': '_id',
				'url': 'product/list',
				"cols": [
					{type:'id'},
					{name:'Name',text: LANG("产品"), type:'index', width: 350, render: 'renderName'},
					{name:'click_rate'},
					{name:'back_reg_rate'}
				],
				"sort": "CreateTime", // 排序字段，默认为展示量
				"param": {
					metrics: ['click_rate', 'back_reg_rate'],
					noAmount: true
				},
				'pager': {'size':8, 'showSizeTypes':0},
				'reqType': 'websocket'
			});

			this.Super('init', arguments);
		},
		renderSize: function(i,val,row,con){
			return row.Width+" x "+row.Height;
		},
		renderName: function(i,val,row,con){
			var html = $('<div class="text-truncate cur_p"/>').attr('title', val).text(val);
			if(row.GameId){
				var gameId = row.GameId ? ' (' + row.GameId + ')' : '';
				html.attr('title', LANG(val) + gameId);
				$('<span class="uk-text-muted"/>').text(gameId).appendTo(html);
			}
			return html;
		}
	});

	exports.selectList = SelectList;

});